from django import template
from django.db import models

register = template.Library()


@register.filter(name="B2aTrans")
def B2aTrans(value):
    ret = value.authors.all()
    li = []
    for k in ret:
        li.append(k.name)
    return "、".join(li)


@register.filter(name="A2bTrans")
def A2bTrans(value):
    ret = value.books.all()
    li = []
    for k in ret:
        li.append("《" + k.name + "》"+"出版社："+k.publisher.name)
    return "  、  ".join(li)
